<?php
$DIR = dirname(__DIR__);
//
$config = [
    'id' => 'basic',
    'language' => 'zh-CN',
    'basePath' => $DIR,// 'E:/web_2015/test/2/web/php/vendor/',
    'vendorPath' => YII_Dir,
    'runtimePath' => YII_Dir . 'runtime',
    'timeZone' => 'PRC',
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'gfdsbcdsaecxzef',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
            'keyPrefix' => 'y'///为了解决不同应用间冲突,这里可以设置一个前缀
            // 'class' => 'app\components\CacheRedis',
        ],
        'user' => [
            'class' => 'app\components\WebUser',
            'enableAutoLogin' => true,
            'loginUrl' => ['/home/public/login'],
        ],
        'errorHandler' => [
            'errorAction' => '/home/i/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),


        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                // 'home/wx.html' => '/home/wx/index',
                "/api/app/call/<id>" => '/api/app/call',
            ],
        ],


        'session' => [
            'class' => 'yii\web\DbSession',
            //  'db' => 'mydb',
            'sessionTable' => 'tbl_session',
        ]

    ],
    'params' => require(__DIR__ . '/params.php'),

    'modules' => [
        'home' => [
            'class' => 'app\modules\home\Module',
        ],
        'admin' => [
            'class' => 'app\modules\admin\Module',
            'defaultRoute' => 'view/index'
        ],
        'api' => [
            'class' => 'app\modules\api\Module',
            'defaultRoute' => 'view/index'
        ],
    ],
    'defaultRoute' => 'home/i/index'


];

if (YII_ENV_DEV) {
    // exit('ssssssf');
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    // $config['modules']['gii'] = 'yii\gii\Module';
    $config['modules']['gii'] = array(
        'class' => 'yii\gii\Module',
        'allowedIPs' => array('192.168.31.*','127.0.0.1', '::1'),    //将此处的IP改为本机客户端目前使用的IP
    );

}

return $config;
